from Tkinter import*
fo = open("input","r")
fr = fo.readline()
fr = fr.split()
def readline_():
	fr = fo.readline()
	fr = fr.split()
si = 0
ri = 0
root = Tk()
can = Canvas(root,height = 780 ,width = 720)
can.pack()
scl = 10
line = scl*10
i = 0
px = range(10,710,int(scl*3))
def notes():	
	global line,scl,C,D,E,F,G,A,B,c,d,e,f,g,a
	(e,f,g,a) = (line-scl*0,line-scl*0.5,line-scl*1,line-scl*1.5)
	(e,d,c,B) = (line-scl*0,line+scl*0.5,line+scl*1,line+scl*1.5)
	(C,D,E,F) = (line+scl*4.5,line+scl*4,line+scl*3.5,line+scl*3)
	(G,A,B,c) = (line+scl*2.5,line+scl*2,line+scl*1.5,line+scl*1)
def oval():
		global i,notes,scl
		can.create_oval(px[i],notes[0],px[i]+scl,notes[0]+scl,fill= "black")
def shtil():
		global i,notes,scl
		can.create_line(px[i]+scl,notes[0]+scl/2,px[i]+scl,notes[0]-scl*3.5)
def two_vosm():
		global i,notes,scl
		can.create_oval(px[i],notes[0],px[i]+scl,notes[0]+scl,fill= "black")
		can.create_oval(px[i+1],notes[1],px[i+1]+scl,notes[1]+scl,fill= "black")
		can.create_line(px[i]+scl,notes[0]+scl/2,px[i]+scl,notes[0]-scl*3.5)
		can.create_line(px[i+1]+scl,notes[1]+scl/2,px[i+1]+scl,notes[1]-scl*3.5)
		can.create_line(px[i]+scl,notes[0]-scl*3.5,px[i+1]+scl,notes[1]-scl*3.5,width = 3)
def chvartolli():
		global i,notes,scl
		can.create_oval(px[i],notes[0],px[i]+scl,notes[0]+scl,fill= "black")
		can.create_oval(px[i+1],notes[1],px[i+1]+scl,notes[1]+scl,fill= "black")
		can.create_oval(px[i+2],notes[2],px[i+2]+scl,notes[2]+scl,fill= "black")
		can.create_oval(px[i+3],notes[3],px[i+3]+scl,notes[3]+scl,fill= "black")
		can.create_line(px[i]+scl,notes[0]+scl/2,px[i]+scl,notes[0]-scl*3.5)
		can.create_line(px[i+1]+scl,notes[1]+scl/2,px[i+1]+scl,notes[1]-scl*3.5)
		can.create_line(px[i+2]+scl,notes[2]+scl/2,px[i+2]+scl,notes[2]-scl*3.5)
		can.create_line(px[i+3]+scl,notes[3]+scl/2,px[i+3]+scl,notes[3]-scl*3.5)
		can.create_line(px[i]+scl,notes[0]-scl*3.5,px[i+3]+scl,notes[3]-scl*3.5,width = 3)
def chvartolli_down():
		global i,notes,scl
		can.create_oval(px[i],notes[0],px[i]+scl,notes[0]+scl,fill= "black")
		can.create_oval(px[i+1],notes[1],px[i+1]+scl,notes[1]+scl,fill= "black")
		can.create_oval(px[i+2],notes[2],px[i+2]+scl,notes[2]+scl,fill= "black")
		can.create_oval(px[i+3],notes[3],px[i+3]+scl,notes[3]+scl,fill= "black")
		can.create_line(px[i],notes[0]+scl/2,px[i],notes[0]+scl*4)
		can.create_line(px[i+1],notes[1]+scl/2,px[i+1],notes[1]+scl*4)
		can.create_line(px[i+2],notes[2]+scl/2,px[i+2],notes[2]+scl*4)
		can.create_line(px[i+3],notes[3]+scl/2,px[i+3],notes[3]+scl*4)
		can.create_line(px[i],notes[0]+scl*4,px[i+3],notes[3]+scl*4,width = 3)
def secstolli():
		global i,notes,scl
		can.create_oval(px[i],notes[0],px[i]+scl,notes[0]+scl,fill= "black")
		can.create_oval(px[i+1],notes[1],px[i+1]+scl,notes[1]+scl,fill= "black")
		can.create_oval(px[i+2],notes[2],px[i+2]+scl,notes[2]+scl,fill= "black")
		can.create_oval(px[i+3],notes[3],px[i+3]+scl,notes[3]+scl,fill= "black")
		can.create_line(px[i]+scl,notes[0]+scl/2,px[i]+scl,notes[0]-scl*3.5)
		can.create_line(px[i+1]+scl,notes[1]+scl/2,px[i+1]+scl,notes[1]-scl*3.5)
		can.create_line(px[i+2]+scl,notes[2]+scl/2,px[i+2]+scl,notes[2]-scl*3.5)
		can.create_line(px[i+3]+scl,notes[3]+scl/2,px[i+3]+scl,notes[3]-scl*3.5)
		can.create_line(px[i]+scl,notes[0]-scl*3.5,px[i+3]+scl,notes[3]-scl*3.5,width = 3)
		can.create_line(px[i]+scl,notes[0]-scl*3,px[i+3]+scl,notes[3]-scl*3,width = 3)
def secstolli_down():
		global i,notes,scl
		can.create_oval(px[i],notes[0],px[i]+scl,notes[0]+scl,fill= "black")
		can.create_oval(px[i+1],notes[1],px[i+1]+scl,notes[1]+scl,fill= "black")
		can.create_oval(px[i+2],notes[2],px[i+2]+scl,notes[2]+scl,fill= "black")
		can.create_oval(px[i+3],notes[3],px[i+3]+scl,notes[3]+scl,fill= "black")
		can.create_line(px[i],notes[0]+scl/2,px[i],notes[0]+scl*4)
		can.create_line(px[i+1],notes[1]+scl/2,px[i+1],notes[1]+scl*4)
		can.create_line(px[i+2],notes[2]+scl/2,px[i+2],notes[2]+scl*4)
		can.create_line(px[i+3],notes[3]+scl/2,px[i+3],notes[3]+scl*4)
		can.create_line(px[i],notes[0]+scl*4,px[i+3],notes[3]+scl*4,width = 3)
		can.create_line(px[i],notes[0]+scl*3.5,px[i+3],notes[3]+scl*3.5,width = 3)
def stan():
	global i,notes,scl,line
	for st in range(line,line+scl*5,scl):
		can.create_line(0,st,720,st)
stan()
notes()
for inp in fr:
	if inp == "/n":
		readline_()
		notes()
		line += scl*10 
		stan()
		i = 0
		continue
	if inp == "r2":
		can.create_text(px[i],B,text = inp)
		i += 1
		continue
	elif inp == "|":
			can.create_line(px[i],e,px[i],D,width = 2)
			i += 1
	elif inp == "CDEF":
		notes = [C,D,E,F]
		chvartolli()
		i += 4
	elif inp == "GABc":
		notes = [G,A,B,c]
		chvartolli()
		i += 4
	elif inp == "/BA^GA":
		notes = [B,A,G,A]
		secstolli()
		can.create_text(px[i+2]-scl,notes[2]+scl/2,text = "#")
		i += 4
	elif inp == "/CDEF":
		notes = [C,D,E,F]
		secstolli()
		i += 4
	elif inp == "edcB":
		notes = [e,d,c,B]
		chvartolli_down()
		i += 4
	elif inp == "/edcB":
		notes = [e,d,c,B]
		secstolli_down()
		i += 4
	elif inp == "/cBAG":
		notes = [c,B,A,G]
		secstolli_down()
		i += 4
	elif inp == "GG":
		notes = [G,G]
		two_vosm()
		i += 2
	elif inp == "FF":
		notes = [F,F]
		two_vosm()
		i += 2
	elif inp == "AA":
		notes = [A,A]
		two_vosm()
		i += 2
	for inp in inp:
		if inp == "G":
			notes = [G]
			oval()
		elif inp == "A":
			notes = [A]
			oval()
		elif inp == "2":
			notes = notes
			shtil()
			i += 1
fo.close()
can.mainloop()
